<?php
namespace app\admin\controller;

use app\admin\controller\Common;
use think\Db;

class Index extends Common
{
    public function index()
    {
        return view();
    }

    function main()
    {
        if ($_SESSION['think']['admin_super'] == 1) {
            $this->redirect('Cert/certList');
            exit;
        }
        if (in_array('Admin/Cert', $_SESSION['think']['rule'])) {
            $this->redirect('Cert/certList');
            exit;
        }
        $this->index();
        exit;
        // //文章数商品数
        $data['article_num'] = Db::name('article')->where("is_del=0")->count();
        $data['admin_num'] = Db::name('admin')->count();
        /*$data['user_num'] = Db::name('user')->where('is_del=0')->count();
        $data['wenke_num'] = Db::name('user')->where('is_del=0 and art_type=1')->count();
        $data['like_num'] = Db::name('user')->where('is_del=0 and art_type=2')->count();
        $data['notice_num'] = Db::name('notice')->where('is_del=0')->count();*/
        $data['mysql_version'] = Db::name('article')->query("SELECT VERSION();");
        return view('main', ['data' => $data]);

    }

    function reboot()
    {
        $str = '/usr/local/php/bin/php /data/wwwroot/workerman/hospital.php start -d';
        $res = system($str);
        addlog($res);
        // $this->redirect('Sign/index');
    }

    function changeLang()
    {
        $lang = input('lang');
        switch ($lang) {
            case 'en':
                cookie('think_var', 'en-us');
                break;
            case 'cn':
                cookie('think_var', 'zh-cn');
                break;
            default:
                cookie('think_var', 'zh-cn');
                break;
        }
    }
}

?>
